Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
Starting Progress Dynamics application windows
When you create a static SmartWindow in the AppBuilder and drop objects onto it, the AppBuilder generates a procedure called
adm-create-objectsto create all of those objects at run time. In Progress Dynamics, most windows are dynamic objects, so one dynamic window procedure, rydyncontw.w, has an empty version ofadm-create-objectsthat acts like a placeholder. The procedure calls to create the window, and its contents are executed at run time rather than being pregenerated into a source code file. The sequence of steps that occurs and the procedures that are run remain the same as for static windows. Theadm-create-objectsprocedure retains the older naming style ofadm-plus a procedure name from an older version of the ADM. The reason for this is that in static windows, we need to allow for the AppBuilder-generated code, which the developer should not edit directly, plus a possible local override procedure that can do additional work when objects are created. Because these are both in the same source procedure in a static environment, they must have different names.As a result, the actual ADM event that is run in a container and published in any child containers is
createobjects. The standard code forcreateobjects, found in the super procedure containr.p, runsadm-create-objects, which executes the AppBuilder-generated code for a static window. If the developer wants to write custom code for this stage of the application, this goes into a local version of thecreateobjectsprocedure, as shown:
Here is an excerpt from an AppBuilder-generated
adm-create-objectsprocedure that serves as a model for running some of the same support procedures in your own code:
The static
adm-create-objectsprocedure, or thecreateobjectscode for dynamic windows, does several things. First, for each SmartObject in the container, it runsconstructObject, which takes the SmartObject procedure name, its parentFramehandle, and its list of instance property settings asINPUTparameters, and returns the procedure handle of the new SmartObject as anOUTPUTparameter. TheconstructObjectprocedure runs the SmartObject as a persistent procedure, parents its default frame (if any) to the frame handle passed in, and runs theset<property>function for each instance property name/value pair passed in. Instance properties are SmartObject properties for which initial values can be defined for a particular instance of the object as used in some container. These properties can be set in the Instance Property dialog box of the SmartObject as the container is assembled, and they are initialized in the following example:
The procedure handle of the new SmartObject instance is returned to
adm-create-objects, which uses it in several other procedure calls.For any SmartObject with a visualization,
repositionObjectis run to position it at run time. Also, for any object that is resizable,resizeObjectis run to size the object appropriately. The presence of theresizeObjectprocedure in the object (or its super procedures) determines whether it should be made resizable. In Progress Dynamics, of course, object positions and sizes are not fixed at design time. The layout manager determines the sizes and relative positions of objects based on the overall window size and on which objects are resizable. But you can use these procedures where needed in your code to adjust sizes and position, as shown:
You could run
repositionobjectfrom your code to adjust default object positions or to position objects you created outside the window definition stored in the Repository, as shown:
You could resize an object based on application requirements, or to make adjustments outside the standard layout manager support.
Once all the SmartObjects have been created, any SmartLinks between those objects are defined. Use the
addLinkprocedure to do this. This is described in the "Managing links in Progress Dynamics applications" section.The AppBuilder also generates calls to
adjustTabOrderto assure that the tabbing order between SmartObjects is either left-to-right/top-to-bottom (the default), or as reset by the developer in the AppBuilder, as shown:
There are two additional properties that are used in Progress Dynamics to size objects proportionally in dynamic windows,
resizeHorizontalandresizeVertical. TheLOGICALproperties indicate whether a visual object can be resized in one dimension or the other or both when the window is initially sized, or when it is resized by a user. The properties are defined for all visual objects and have the default values shown in Table 5–1.
Table 5–1: Default values of resize properties for visual objects Object resizeHorizontal properties resizeVertical properties ViewerFALSEFALSE BrowserTRUETRUE WindowTRUETRUE ToolbarTRUEFALSE
Note that you can override these default values. You can set these properties for individual objects to change the default resizing, for example, if you want a browser to be a fixed size in one or both dimensions.
You can set these properties in the Container Builder in the instance section of the main window.
Now, when you run the
Customerbrowse window, the browser is a fixed height, as you can see in Figure 5–2.Figure 5–2: Customer selection window
![]()
The
createobjectsandadm-create-objectsprocedures are part of a sequence that occurs when a container is run. It’s important to know the steps in this sequence and where the appropriate places are to put custom application code.When you run SmartObject code from
constructObject, any code in its main block is executed first. Custom code that should be executed as soon as the object is run, before anything else happens, can be placed in the main block. Remember that at this time the object has no links to other objects, so you cannot refer to itsData-Sourceor other such connections; its instance property values also are not yet set, so you cannot refer to them. If you try to set them, the values set by the container override your settings. If you create static objects and need code to be executed immediately when the object is run, you can put it in the main block (this is true for any persistent procedure). If you’re using dynamic objects, then you’ll have to write a super procedure where you override standard procedures or respond to events.For the remainder of this chapter, assume that any references to local application code should be taken to mean either code written in a static SmartObject procedure or (preferably in most cases) code written into a custom super procedure for a dynamic object.
Custom code for a window that must reference its contained SmartObjects as soon as they are created should go into a local
createobjectsprocedure. If you look at the sameadm-create-objectsprocedure above, note that it references theCurrentPageproperty, and then executes a block of aCASEstatement depending on the current page number. When the window is first run, itsCurrentPageis zero. As each additional page (if any) is first referenced,createobjectsandadm-create-objectsare run again to create the objects on that page.If you define a local
createObjectsprocedure, remember that it runs multiple times if the window has more than just the default page zero, so check theObjectCreatedproperty. It will be false the first time and true on each subsequent call. You can also check theCurrentPageproperty in the same way that adm-create-objects does. EachCASEshould contain aRUN SUPERstatement to invoke the code inadm-create-objectsfor that page, with the custom code added either before or after that statement, as appropriate.Code that must do something immediately before the objects on a page are created can be placed in
createobjectsbefore theRUNSUPERstatement for that page. Code that must be executed after the objects are created (which seems more likely, since, of course, you cannot access the objects on a page before they are run) must be written after theRUNSUPERstatement for thatCASE. For example, acreateobjectsprocedure can add additional links between objects that have just been created (based on dynamic application requirements); or it can set additional property values that are not instance properties or that must be set conditionally based on application requirements; it might reposition or reorder objects; or other such things. At this point in the window’s life, all the objects on the current page have been created, positioned, and resized; their frame handles have been parented to the window’s frame; their instance property values have been set; and their links and tab order have been established. But they have not been initialized; that is, theinitializeObjectevent procedure has not been run, so visual objects have not been viewed or enabled; queries have not been opened, and so on.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |